%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/connections/pagination-before-end.variables"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 12, 13, 51, 52, 14, 17, 18<br />2: PgSelect[11], PgSelect[23]<br />ᐳ: Access[33]<br />3: Connection[15], PgSelectRows[25]<br />ᐳ: 24, 26, 27<br />4: ConnectionItems[19]<br />ᐳ: 32, 34, 35, 36"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 15, 33, 19, 14, 27, 34, 36<br /><br />ROOT Connectionᐸ11ᐳ[15]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 33, 14<br /><br />ROOT __Item{3}ᐸ19ᐳ[28]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 28, 29, 14, 38<br /><br />ROOT Edge{3}[29]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 39, 14<br /><br />ROOT PgSelectSingle{4}ᐸmessagesᐳ[39]<br />1: <br />ᐳ: 40, 41<br />2: PgSelect[42]<br />3: PgSelectRows[47]<br />ᐳ: First[46], PgSelectSingle[48]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 48<br /><br />ROOT PgSelectSingle{5}ᐸusersᐳ[48]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect11[["PgSelect[11∈0] ➊<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[14]<br />- Constantᐸ3ᐳ[52]"]]:::plan
    Lambda17{{"Lambda[17∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[51]"}}:::plan
    Lambda18{{"Lambda[18∈0] ➊<br />ᐸparseCursorᐳ"}}:::plan
    Lambda17 & Lambda18 --> PgSelect11
    PgSelect23[["PgSelect[23∈0] ➊<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[14]<br />- Constantᐸ3ᐳ[52]"]]:::plan
    Lambda17 & Lambda18 --> PgSelect23
    Connection15[["Connection[15∈0] ➊<br />ᐸ11ᐳ<br />Dependents: 4<br />More deps:<br />- Constantᐸ3ᐳ[52]"]]:::plan
    PgSelect11 & Lambda18 --> Connection15
    Object14{{"Object[14∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 3"}}:::plan
    Access12{{"Access[12∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access13{{"Access[13∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access12 & Access13 --> Object14
    Access9{{"Access[9∈0] ➊<br />ᐸ0.valueᐳ"}}:::plan
    __Value0["__Value[0∈0] ➊<br />ᐸvariableValuesᐳ"]:::plan
    __Value0 --> Access9
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access12
    __Value2 --> Access13
    Access9 --> Lambda18
    ConnectionItems19[["ConnectionItems[19∈0] ➊<br />Dependents: 3<br />More deps:<br />- Connection[15]"]]:::plan
    First24{{"First[24∈0] ➊"}}:::plan
    PgSelectRows25[["PgSelectRows[25∈0] ➊"]]:::plan
    PgSelectRows25 --> First24
    PgSelect23 --> PgSelectRows25
    PgSelectSingle26{{"PgSelectSingle[26∈0] ➊<br />ᐸmessagesᐳ"}}:::plan
    First24 --> PgSelectSingle26
    First32{{"First[32∈0] ➊<br />More deps:<br />- ConnectionItems[19]"}}:::plan
    Access33{{"Access[33∈0] ➊<br />ᐸ11.cursorDetailsᐳ<br />Dependents: 3"}}:::plan
    PgSelect11 --> Access33
    Last35{{"Last[35∈0] ➊<br />More deps:<br />- ConnectionItems[19]"}}:::plan
    PageInfo22{{"PageInfo[22∈1] ➊<br />More deps:<br />- Connection[15]"}}:::plan
    Access30{{"Access[30∈1] ➊<br />ᐸ15.hasNextPageᐳ<br />More deps:<br />- Connection[15]"}}:::plan
    Access31{{"Access[31∈1] ➊<br />ᐸ15.hasPreviousPageᐳ<br />More deps:<br />- Connection[15]"}}:::plan
    Edge29{{"Edge[29∈3]"}}:::plan
    __Item28[/"__Item[28∈3]<br />ᐸ19ᐳ<br />More deps:<br />- ConnectionItems[19]"\]:::itemplan
    PgCursor38{{"PgCursor[38∈3]<br />More deps:<br />- Access[33]"}}:::plan
    __Item28 & PgCursor38 --> Edge29
    __Item28 --> PgCursor38
    PgSelectSingle39{{"PgSelectSingle[39∈4]<br />ᐸmessagesᐳ"}}:::plan
    __Item28 --> PgSelectSingle39
    PgSelect42[["PgSelect[42∈5]<br />ᐸusersᐳ<br />More deps:<br />- Object[14]"]]:::plan
    PgClassExpression41{{"PgClassExpression[41∈5]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression41 --> PgSelect42
    PgClassExpression40{{"PgClassExpression[40∈5]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle39 --> PgClassExpression40
    PgSelectSingle39 --> PgClassExpression41
    First46{{"First[46∈5]"}}:::plan
    PgSelectRows47[["PgSelectRows[47∈5]"]]:::plan
    PgSelectRows47 --> First46
    PgSelect42 --> PgSelectRows47
    PgSelectSingle48{{"PgSelectSingle[48∈5]<br />ᐸusersᐳ"}}:::plan
    First46 --> PgSelectSingle48
    PgClassExpression49{{"PgClassExpression[49∈6]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle48 --> PgClassExpression49
    PgClassExpression50{{"PgClassExpression[50∈6]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression49 o--o PgClassExpression50

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value0,__Value2,Access9,PgSelect11,Access12,Access13,Object14,Connection15,Lambda17,Lambda18,ConnectionItems19,PgSelect23,First24,PgSelectRows25,PgSelectSingle26,First32,Access33,Last35 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PageInfo22,Access30,Access31 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item28,Edge29,PgCursor38 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle39 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression40,PgClassExpression41,PgSelect42,First46,PgSelectRows47,PgSelectSingle48 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression49,PgClassExpression50 bucket6

